<?php
$archi=trim($coop->getNombre());
header("Pragma: ");
header('Cache-control: ');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename='Cuadro_Turnos_$archi.ods'");
?>    
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    </head>

<h1>Listado de Turnos Normales Cooperativa <?php echo $coop->getNombre() ?></h1>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>


<div id="fondos2" align="center" class="cajatablausuariobus">
    <table border="3">

        <tbody>
            <tr>
                <td>
                    Fecha/Ruta 
                </td>
                <?php
                foreach ($vectorfinal as $fret):
                    $q = Doctrine_Query::create()
                            ->from('ruta r')
                            ->where('r.id_ru=?', $fret->getIdRu());
                    $rub = $q->fetchOne();
                    ?>
                    <td>
                        <?php echo $fret->getPrioridad() ?>
                        <br></br>
                        <?php echo $rub->getSalida() ?>--<?php echo $rub->getLlegada() ?>
                        <br></br>
                        <?php echo $fret->getHora() ?>

                    </td>
                <?php endforeach; ?>

            </tr>
            <?php
            $dias = cal_days_in_month(CAL_GREGORIAN, $mes, $anio);
            $arranque = 0;
            for ($j = 0; $j < count($vectorbusfinal); $j++) {
                if ($vectorbusfinal[$j]->getDisco() == $businicial) {
                    $arranque = $j;
                }
            }
            for ($i = 1; $i <= $dias; $i++) {
                ?>
                <tr>
                    <td><?php echo $i ?></td>  
                    <?php
                    $busespresentados = 0;
                    $auxarranque = $arranque;
                    for ($k = 0; $k < count($vectorfinal); $k++) {
                        if ($auxarranque + $busespresentados == count($vectorbusfinal)) {
                            $auxarranque = 0;
                            $busespresentados = 0;
                        }
                        ?>
                        <td><?php echo $vectorbusfinal[$auxarranque + $busespresentados]->getDisco() ?></td>
                        <?php
                        $busespresentados++;
                    }
                    $arranque--;
                    if ($arranque < 0) {
                        $arranque = count($vectorbusfinal) - 1;
                    }
                    ?>
                </tr>   
                <?php
            }
            ?>
        </tbody>
    </table>
</div>


